<template>
  <div class="shoppingMain">
    <!-- header -->
    <el-row :span="24" class="viewHeader">
      <header-bar></header-bar>
    </el-row>
    <!-- content -->
    <router-view></router-view>
    <!-- footer -->
    <div class="placeholderBox" v-if="this.$route.path === '/shopping'"></div>
    <el-row :span="24" class="viewFooter" v-if="this.$route.path === '/shopping'">
      <footer-nav></footer-nav>
    </el-row>
  </div>
</template>

<script type="text/ecmascript-6">
import headerBar from '../common/headerBar'
import footerNav from '../common/footerNav'
import {loadFromSession} from '../common/sessionStorage'
export default {
  props: [], // 子组件接收信息
  components: { headerBar, footerNav, loadFromSession },
  data () {
    return {}
  },
  created () {
    if (loadFromSession('setToken') === undefined || loadFromSession('setUser') === undefined) {
      window.location.href = ''
    }
    let user = loadFromSession('setUser')
    let token = loadFromSession('setToken')
    let title = loadFromSession('setTitle')
    this.$store.dispatch('setUser', user)
    this.$store.dispatch('setToken', token)
    this.$store.dispatch('setTitle', title)
  }
}
</script>

<style lang="scss" type="stylesheet/scss">
.shoppingMain {
  .placeholderBox {
    height: 60px;
    background-color: transparent;
  }
  .viewFooter {
    position: fixed;
    bottom: 0;
    width: 100%;
  }
}
</style>
